package edu.tsinghua.ddb.site;

public class SiteAttributes {
	public String name;
	public String ipAddr;
	public int rmiPort;
	public long lastAlive;
	public long rtt;

	public SiteAttributes(String name, String ipAddr, int rmiPort) {
		this.name = name;
		this.ipAddr = ipAddr;
		this.rmiPort = rmiPort;
		touch();
	}

	public void touch() {
		lastAlive = System.currentTimeMillis();
	}

	public boolean isOverDate() {
		return TTL() < 0;
	}

	private long getThreadHold() {
		return 5 * 1000;
	}

	public long TTL() {
		return getThreadHold() - (System.currentTimeMillis() - lastAlive);
	}
}
